//
// Created by LH on 2017/8/29.
//
#include <iostream>

using namespace std;
int q[2000];
int head = 0, tail = 0;
int e[50][50];
bool book[50];
int n;
int sum = 0;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> e[i][j];
        }
    }
    book[1] = true;
    q[tail] = 1;
    tail++;
    while (head < tail)
    {
        int root = q[head];
        cout << root << " ";
        for (int t=1;t<=n;t++)
        {
            if (!book[t] && e[root][t] == 1)
            {
                q[tail] = t;
                tail++;
                book[t] = true;
            }
        }
        head++;
    }

    return 0;
}

/*
5
0 1 1 2 1
1 0 2 1 2
1 2 0 2 1
2 1 2 0 2
1 2 1 2 0
*/